package com.example.bilibili_miaosha.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespBean {
    private Integer code;
    private String Message;
    private Object obj;

    /**
     * @Description: 成功返回结果
     * @Param: [] 无参数
     * @return: com.example.bilibili_miaosha.utils.RespBean
     * @Author: 弓川
     * @Date: 2022/3/28
     */
    public static RespBean success() {
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), null);
    }

    /**
     * @Description: 成功返回结果，携带对象
     * @Param: [object] 携带对象
     * @return: com.example.bilibili_miaosha.utils.RespBean
     * @Author: 弓川
     * @Date: 2022/3/28
     */
    public static RespBean success(Object object) {
        return new RespBean(RespBeanEnum.SUCCESS.getCode(), RespBeanEnum.SUCCESS.getMessage(), object);
    }

    /**
     * @Description: 失败返回结果
     * @Param: 枚举公共类型，包括错误码和message
     * @return:
     * @Author: 弓川
     * @Date: 2022/3/28
     */
    public static RespBean error(RespBeanEnum respBeanEnum) {
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    /**
     * @Description: 失败返回结果
     * @Param: 枚举公共类型，包括错误码和message   还有失败返回对象
     * @return:
     * @Author: 弓川
     * @Date: 2022/3/28
     */
    public static RespBean error(RespBeanEnum respBeanEnum, Object object) {
        return new RespBean(respBeanEnum.getCode(), respBeanEnum.getMessage(), object);
    }

}
